<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<!-- build:css /css/main.css -->
		<link href="/css/mui.css" rel="stylesheet" />
		<link href="/css/iconfont.css" rel="stylesheet" />
		<link href="/css/common.css" rel="stylesheet" />
		<!-- endbuild -->
		<!-- build:css /css/login-min.css -->
		<link href="/css/login.css" rel="stylesheet" />
		<!-- endbuild -->
	</head>

	<body>
		<header class="mui-bar mui-bar-nav u-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">重设密码</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">

				<div class="mui-input-row">
					<label><span class="mui-icon mui-icon-locked"></span></label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>

				<div class="mui-input-row">
					<label><span class="mui-icon mui-icon-locked"></span></label>
					<input id='rePassword' type="password" class="mui-input-clear mui-input" placeholder="请再次输入密码">
				</div>
				<div class="mui-input-row" id="err">

				</div>
			</form>
			<div class="mui-content-padded">
				<button id='sendPassword' class="mui-btn mui-btn-block mui-btn-danger">提交</button>
			</div>
		</div>
		<!-- build:js /js/vendor.js -->
		<script src="/js/mui.min.js"></script>
		<!-- bower:js -->
		<script src="/bower_components/mockjs/dist/mock.js"></script>
		<script src="/bower_components/zepto/zepto.js"></script>
		<script src="/bower_components/Zepto-Cookie/zepto.cookie.js"></script>
		<!--  endbower -->
		<!-- endbuild -->
		<!-- build:js /js/main.js -->
		<script src="/js/common.js"></script>
		<script src="/js/app.js"></script>
		<!-- endbuild -->
		<script>
			(function(mui, doc) {
				mui.init();
				var tokenVal = $.fn.cookie('token');
				ifLogin(tokenVal);
				mui.ready(function() {
					var settings = app.getSettings();
					var setButton = $('#sendPassword');
					var passwordBox = $('#password');
					var rePasswordBox = $('#rePassword');
					var customer = localStorage.getItem('customer')
					setButton.on('tap', function(event) {
						var setInfo = {
							password: passwordBox.val(),
							rePassword: rePasswordBox.val()
						};
						app.setPassword(setInfo, function(err) {
							if(err) {
								$("#err").html(err);
								return;
							}
							$.ajax({
								url: __BATE__ + 'api/resetPw',
								type: 'post',
								data: {
									password: passwordBox.val(),
									token: tokenVal,
									code: codeVal
								},
								success: function(data) {
									if(data.ret_msg == '重置密码成功') {

										toLoginView();
									} else {
										$('#err').html(data.ret_msg);
									}

								}
							});
						});
					});
				});
			}(mui, document));
		</script>
	</body>

</html>